﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace WpfDecorator
{
    public class SimpleTextBlockAdorner : Adorner
    {
        private TextBlock _textBlock;

        public SimpleTextBlockAdorner(UIElement adornerElement)
            : base(adornerElement)
        {
            _textBlock = new TextBlock();
            _textBlock.Foreground = Brushes.Red;
            _textBlock.Text = "AdornerText";
        }

        protected override int VisualChildrenCount
        {
            get
            {
                return 1;
            }
        }

        protected override Visual GetVisualChild(int index)
        {
            return _textBlock;
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            _textBlock.Arrange(new Rect(new Point(-10, 20), _textBlock.DesiredSize));
            return base.ArrangeOverride(finalSize);
        }
    }
}
